<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>第三题</title>
</head>
<body>
<pre>
from datetime import datetime
from functools import wraps

def log(logfile='out.log'):
 def logging(func):
  @wraps(func)
  def wrapped(*args, **kwargs):
   log = f"[{datetime.now()}] {func.__name__} was called"
   with open(logfile, 'a') as fd:
    fd.write(log + '\n')
   return func(*args, **kwargs)
  return wrapped
 return logging

 @log()
 def func1():
  pass

 @log(logfile='func2.log')
 def func2():
  pass

 func1()
 func2()
</pre>
</body>
</html>